<?php

require_once dirname(__FILE__).'/../lib/propiedadGeneratorConfiguration.class.php';
require_once dirname(__FILE__).'/../lib/propiedadGeneratorHelper.class.php';

/**
 * propiedad actions.
 *
 * @package    inmobiliaria
 * @subpackage propiedad
 * @author     Your name here
 * @version    SVN: $Id: actions.class.php 23810 2009-11-12 11:07:44Z Kris.Wallsmith $
 */
class propiedadActions extends autoPropiedadActions
{

  public function executeEdit(sfWebRequest $request)
  {
    $this->propiedad = $this->getRoute()->getObject();
    $this->form = $this->configuration->getForm($this->propiedad);
    $this->form->setDefault('zona',array('pais_id'=>$this->propiedad->getZona()->getCiudad()->getProvincia()->getPaisId(),'provincia_id'=>$this->propiedad->getZona()->getCiudad()->getProvinciaId(),'ciudad_id'=>$this->propiedad->getZona()->getCiudadId(),'zona_id'=>$this->propiedad->getZonaId()));

  }

/*

 protected function processForm(sfWebRequest $request, sfForm $form)
  {

    $misvalores=$request->getParameter($form->getName());


    $temp=$misvalores['zona'];
    $misvalores['zona_id']=$temp['zona_id'];

    $form->bind($misvalores, $request->getFiles($form->getName()));
    if ($form->isValid())
    {
      $notice = $form->getObject()->isNew() ? 'The item was created successfully.' : 'The item was updated successfully.';

      try {
        $propiedad = $form->save();
      } catch (Doctrine_Validator_Exception $e) {

        $errorStack = $form->getObject()->getErrorStack();

        $message = get_class($form->getObject()) . ' has ' . count($errorStack) . " field" . (count($errorStack) > 1 ?  's' : null) . " with validation errors: ";
        foreach ($errorStack as $field => $errors) {
            $message .= "$field (" . implode(", ", $errors) . "), ";
        }
        $message = trim($message, ', ');

        $this->getPerfil()->setFlash('error', $message);
        return sfView::SUCCESS;
      }

      $this->dispatcher->notify(new sfEvent($this, 'admin.save_object', array('object' => $propiedad)));

      if ($request->hasParameter('_save_and_add'))
      {
        $this->getPerfil()->setFlash('notice', $notice.' You can add another one below.');

        $this->redirect('@propiedad_new');
      }
      else
      {
        $this->getPerfil()->setFlash('notice', $notice);

        $this->redirect(array('sf_route' => 'propiedad_edit', 'sf_subject' => $propiedad));
      }
    }
    else
    {
      $this->getPerfil()->setFlash('error', 'The item has not been saved due to some errors.', false);
    }
  }
*/

public function executeListFotos(sfWebRequest $request)
  { 
 
	$idprop=$this->getRequestParameter('id');
	$this->getRequest()->setParameter('propiedad_id', $idprop);

	$this->forward('foto','index');
  }

}
